package isjinhao.jlox.grammar.statement.represention;


import isjinhao.jlox.grammar.statement.visitor.StatementPrintVisitor;
import isjinhao.jlox.grammar.statement.visitor.StatementVisitor;

/**
 * Statement对象的执行会产生side effect，比如改变变量的值，在屏幕输出数据，切换环境。
 * @Author ISJINHAO
 * @Date 2021/2/22 18:46
 */
public abstract class Statement {

    StatementPrintVisitor printVisitor = new StatementPrintVisitor();

    public abstract <R> R accept(StatementVisitor<R> statementVisitor);

    @Override
    public String toString() {
        return toString(0);
    }

    public String toString(int length) {
        return printVisitor.visit(this, length);
    }

}